package database_layer;

/**
 * A class which holds a set of common values which are used
 * in the entire web service.
 */
public final class Common 
{
	/* Table names */
	public static final String usersTable = "users";
	public static final String coursesTable = "courses";
	public static final String registeredTable = "registered";
	public static final String sessionsTable = "sessions";
	public static final String XSTTable = "xst";
	/* Users table fields */
	public static final String usernameField = "username"; /* Also used for registered & xst tables */
	public static final String passwordField = "password";
	public static final String firstNameField = "first_name";
	public static final String lastNameField = "last_name";
	public static final String phoneField = "phone_number";
	public static final String adminField = "is_admin";
	public static final String addressField = "address";
	public static final String photoField = "photo";
	
	/* Courses table fields */
	public static final String courseNameField = "course_name"; /* Also used for sessions & registered tables */
	public static final String descriptionField = "description";
	public static final String creditPointsField = "credit_pts";
	public static final String capacityField = "capacity";
	public static final String alreadyRegisteredField = "registered";
	public static final String groupNumberField = "group_number"; /* Also used in the sessions table */
	public static final String courseCreatorField = "course_creator";
	
	/* Sessions table fields */
	public static final String dayField = "day";
	public static final String startingTimeField = "start";
	public static final String durationField = "duration";
	public static final String endingTimeField = "end";
	
	/* Error codes */
	public static final int    NO_ERROR = 0;
	public static final int    ENTRY_EXISTS = 1;
	public static final int    ENTRY_DOESNT_EXIST = 2;
	public static final int    INTERNAL_DB_ERROR = 3;
	public static final int    ILLEGAL_OPERATION = 4;
	public static final int    OVERLAPPING_ENTRIES = 5;
	public static final int    UNAUTHORIZED_OPERATION = 6;
	public static final int    USER_CONNECTED = 7;
	public static final int    BAD_PARAMETERS = 8;
	public static final int    INTERNAL_ERROR = 9;
	
	/* Assignment constrains */
	public static final int    MAX_GROUPS_FOR_USER = 3;
	
	/* User type */
	public static final String studentType = "Student";
	public static final String adminType = "Admin";
	
	public static final String days[] = { "none", "sunday", "monday", "tuesday",
										  "wednesday", "thursday", "friday", "saturday" };
	
	/* Search scores */
	public static final int NAME_MATCH_SCORE = 2;
	public static final int DESCRIPTION_MATCH_SCORE = 1;
	
	/* Authenticatin string */
	public static final String adminAuthentication = "236369HW5";
	
	/* Context variable names from web.xml */
	public static final String initDriverName = "databaseDriver";
	public static final String initDatabaseAddress = "databaseAddress";
	public static final String initDatabaseUsername = "databaseUsername";
	public static final String initDatabasePasword = "databasePassword";
	public static final String initTestModeIndicator = "testModeIndicator";
}

